const mongoose = require("mongoose");

mongoose.connect("mongodb://127.0.0.1:27017/Samsung");

const db = mongoose.connection
db.on('error', ()=>{
    console.log('数据库连接失败');
})

db.on('open', ()=>{
    console.log('数据库连接成功');
})

const Schema = mongoose.Schema;
// --------------------------------------------------------------
// 创建商品列表骨架
const taobaoSchema = new Schema({
    name:String,
    productImage:String,
    pPrice:String,
    title:String,
    image:String,
    skuld:String,
    jdPrice:String,
    groupld:String,
    currentPrice:String
});

const taobao = mongoose.model("taobaogoods",taobaoSchema);
// --------------------------------------------------------------
// --------------------------------------------------------------
// 创建商品列表骨架
const userSchema = new Schema({
    username:String,
    password:String,
    tel:String
});

const user = mongoose.model("user",userSchema);
// --------------------------------------------------------------

module.exports = {
    taobao,
    user
}